import { createRouter, createWebHashHistory } from "vue-router";

const routes = [
  {
    path: "/",
    component: () => import("@/components/layout/Layout.vue"),
    redirect: "/home",
    children: [
      {
        path: "/home",
        name: "Home",
        component: () => import("@/views/Home.vue"),
        meta: { title: "首页" },
      },
      {
        path: "/task",
        name: "Task",
        component: () => import("@/views/Task/Task.vue"),
        meta: { title: "需求任务管理" },
      },
      {
        path: "/test2",
        name: "Test2",
        component: () => import("@/views/TestCase/TestCase.vue"),
        meta: { title: "测试用例管理" },
      },
    ],
  },
  {
    path: "/login",
    name: "Login",
    component: () => import("@/views/Login.vue"),
    meta: { title: "登录" },
  },
  {
    path: "/redirect",
    component: () => import("@/components/layout/Layout.vue"),
    hidden: true,
    children: [
      {
        path: "/redirect/:path(.*)",
        component: () => import("@/views/Redirect.vue"),
      },
    ],
  },
  {
    path: "/:pathMatch(.*)*",
    redirect: "/",
  },
];

const router = createRouter({
  history: createWebHashHistory(process.env.BASE_URL),
  routes,
});

export default router;
